package com.tjsinfo.tjsoa.worklog.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.system.vo.User;
import com.tjsinfo.tjsoa.worklog.dao.IWorkLogUserDAO;
import com.tjsinfo.tjsoa.worklog.sqlmap.WorkLogDefine;

public class WorkLogSetDefineFromAction extends Action{
	private IWorkLogUserDAO workLogUserDAO;
	public IWorkLogUserDAO getWorkLogUserDAO() {
		return workLogUserDAO;
	}


	public void setWorkLogUserDAO(IWorkLogUserDAO workLogUserDAO) {
		this.workLogUserDAO = workLogUserDAO;
	}
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		String type = "D";
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute("user");
		Integer userid = user.getUser_id();
		WorkLogDefine workLogDefine = new WorkLogDefine();
		workLogDefine.setTjsUserByUserId(userid);
		workLogDefine.setType(type);
		List list = 	workLogUserDAO.selectNoDefine(workLogDefine);
		List list2 = 	workLogUserDAO.selectDefine(workLogDefine);
		request.setAttribute("definenot", list);
		request.setAttribute("define", list2);
		request.setAttribute("type", type);
		if(request.getAttribute("start") != null){
			request.setAttribute("start",1);
		}
		return mapping.findForward("ok");
	}

}
